/*
 * @Author: 追逐的娃 kangchao_php@163.com
 * @Date: 2024-07-03 11:20:48
 * @LastEditors: 追逐的娃 kangchao_php@163.com
 * @LastEditTime: 2024-10-12 14:04:27
 * @FilePath: \vue-project\src\api\system.js
 * @Description: 
 * 
 */
import request from '@/utils/request.js'
/**
 * 获取菜单
 * @param {*} page 页码 
 */
export const getMenus = (page = 1) => {
  return request.get(`menus/${page}`)
}


/**
 * 新增菜单 和 编辑
 * @param {*} id 菜单id 
 * @param {*} data  菜单信息
 */
export const saveRules = (data, id = '') => {
  let url = id ? `/menus/${id}/update` : `/menus/save`
  return request.post(url, data)
}

/**
 * 删除菜单
 * @param {*} id 需要删除的菜单id 
 */
export const deleteRules = (id) => {
  return request.post(`menus/${id}/delete`)
}

/**
 * 改变菜单状态
 * @param {*} id 
 */
export const updateStatus = (id) => {
  return request.post(`rule/${id}/update_status`)
}

/**
 * 获取角色
 * @param {*} page 页码 
 */
export const getRoles = (page = 1) => {
  return request.get('/role/' + page)
}

/**
 * 新增角色 和 编辑
 * @param {*} id 角色id 
 * @param {*} data  角色信息
 */
export const saveRoles = (data, id = '') => {
  let url = id ? `role/${id}` : `role`
  return request.post(url, data)
}

/**
 * 删除角色
 * @param {*} id 需要删除的角色id 
 */
export const deleteRoles = (id) => {
  return request.post(`role/${id}/delete`)
}

/**
 * 设置角色权限
 */
export const setRoleRule = () => {
  return request.post(`role/set_rules`)
}


/**
 * 改变角色状态
 * @param {*} id 
 */
export const updateRoleStatus = (id) => {
  return request.post(`role/${id}/update_status`)
}

/**
 * 获取系统设置
 * @returns 
 */
export const getSystemConfig = () => {
  return request.get('sysconfig')
}

/**
 * 设置系统设置
 * @returns 
 */
export const setSystemConfig = () => {
  return request.post('sysconfig')
}

export const editorUpload = (file) => {
  const formData = new FormData()
  formData.append('file', file)
  return request.post('/upload', { data: formData })
}


//导出这个常量就是图片上传地址
export const uploadImageActioc = import.meta.env.VITE_APP_BASE_API + '/upload'



